package behavior.TemplateMethod;

/**
 * @author pengcheng
 * @version V1.0
 * @description 抽象类
 * @date 2019/04/03 17:16
 */
public abstract class CaffeineBeverageWithHook  {
    final void  prepareRecipe(){
        boilWater();
        brew();
        pourInCup();
        if(customerWantsCondiments()){  //如果顾客需要添加调料，我们才会调用addCondiments()方法
            addCondiments();
        }
    }

    abstract void brew();

    abstract void addCondiments();

    void boilWater(){
        System.out.println("Boiling water...");
    }

    void pourInCup(){
        System.out.println("Pouring into Cup...");
    }

    public boolean customerWantsCondiments(){
        return true;
    }
}
